package com.suypower.carManage.action;

import javax.servlet.ServletException;

import com.jarp.db.DAO;
import com.opensymphony.xwork2.ActionSupport;
import com.suypower.carManage.comm.ConstUtil;

public class PeccancyAction extends ActionSupport {

	private String id;
	private String car_code;
	private String driver;
	private String time;
	private String detail;
	private String area;
	private String process;
	private String remark;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getCar_code() {
		return car_code;
	}

	public void setCar_code(String carCode) {
		car_code = carCode;
	}

	public String getDriver() {
		return driver;
	}

	public void setDriver(String driver) {
		this.driver = driver;
	}

	public String getTime() {
		return time;
	}

	public void setTime(String time) {
		this.time = time;
	}

	public String getDetail() {
		return detail;
	}

	public void setDetail(String detail) {
		this.detail = detail;
	}

	public String getArea() {
		return area;
	}

	public void setArea(String area) {
		this.area = area;
	}

	public String getProcess() {
		return process;
	}

	public void setProcess(String process) {
		this.process = process;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String execute() {
		String res = "";
		DAO dao = new DAO();
		String sql = "";
		if (id != null && !id.equals("")) {
			sql = "UPDATE tb_peccancy SET car_code = '" + car_code
					+ "', driver = '" + driver + "', time = '" + time
					+ "', detail = '" + detail + "', area = '" + area
					+ "', process = '" + process + "', remark = '" + remark
					+ "' where id=" + id;
		} else {
			sql = "INSERT INTO tb_peccancy(car_code,driver,time,detail,area,process,remark)VALUES('"
					+ car_code
					+ "','"
					+ driver
					+ "','"
					+ time
					+ "','"
					+ detail
					+ "','" + area + "','" + process + "','" + remark + "')";
		}

		int count = 0;
		try {
			count = dao.execCommand(ConstUtil.DBNAME, sql);
			if (count > 0) {
				res = this.SUCCESS;
			} else {
				res = this.ERROR;
			}
		} catch (ServletException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return res;
	}
}
